1 /*
2 * Copyright (C) 2007 The Guava Authors
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17 package com.google.common.base;
18
19 import com.google.common.annotations.GwtCompatible;
20
21 import java.nio.charset.Charset;
22
23 /**
24 * Contains constant definitions for the six standard {@link Charset} instances, which are
25 * guaranteed to be supported by all Java platform implementations.
26 *
27 * <p>Assuming you're free to choose, note that <b>{@link #UTF_8} is widely preferred</b>.
28 *
29 * <p>See the Guava User Guide article on <a
30 * href="http://code.google.com/p/guava-libraries/wiki/StringsExplained#Charsets">
31 * {@code Charsets}</a>.
32 *
33 * @author Mike Bostock
34 * @since 1.0
35 */
36 @GwtCompatible(emulated = true)
37 public final class Charsets {
38 private Charsets() {}
39
40 /**
41 * UTF-8: eight-bit UCS Transformation Format.
42 *
43 * <p><b>Note for Java 7 and later:</b> this constant should be treated as deprecated; use
44 * {@link java.nio.charset.StandardCharsets#UTF_8} instead.
45 *
46 */
47 public static final Charset UTF_8 = Charset.forName("UTF-8");
48
49 /*
50 * Please do not add new Charset references to this class, unless those character encodings are
51 * part of the set required to be supported by all Java platform implementations! Any Charsets
52 * initialized here may cause unexpected delays when this class is loaded. See the Charset
53 * Javadocs for the list of built-in character encodings.
54 */
55 }